import java.io.Serializable;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;


public class SequenceFactory implements Serializable{
	private static final long serialVersionUID = 1L;

	public ISequence buildSequence(String param) {
	    Class<?> classe;
	    ISequence isequence = null;
		
	    try { // Instanciation dynamique
			classe = Class.forName(param);
		    Constructor<?> ct= classe.getConstructors()[0]; // On recupere son constructeur
		    isequence =  (ISequence)ct.newInstance();
		} catch (ClassNotFoundException e) {
			System.out.println("ERROR: Class to build sequence not found.");
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			System.out.println("ERROR: Unable to instantiate class " + param);
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		} 
		return isequence;
	}

}
